
$('#questions').on('hidden.bs.modal', function () {
            start();
})

function alphaValidator(event) {
    var key = event.keyCode;
    if(event.altKey && (key>=96 && key<=105)){
        $('input').blur();
    }
    return ((key >= 65 && key <= 90) || key === 8 || key === 32 || key === 222);
};

var	clsStopwatch = function() {
		// Private vars
		var	startAt	= 0;	// Time of last start / resume. (0 if not running)
		var	lapTime	= 0;	// Time on the clock when last stopped in milliseconds
 
		var	now	= function() {
				return (new Date()).getTime(); 
			}; 
 
		// Public methods
		// Start or resume
		this.start = function() {
				startAt	= startAt ? startAt : now();
			};
 
		// Stop or pause
		this.stop = function() {
				// If running, update elapsed time otherwise keep it
				lapTime	= startAt ? lapTime + now() - startAt : lapTime;
				startAt	= 0; // Paused
			};
 
		// Reset
		this.reset = function() {
				lapTime = startAt = 0;
			};
 
		// Duration
		this.time = function() {
				return lapTime + (startAt ? now() - startAt : 0); 
			};
	};
 
var x = new clsStopwatch();
var $time;
var clocktimer;
 
function pad(num, size) {
	var s = "0000" + num;
	return s.substr(s.length - size);
}
 
function formatTime(time) {
	var h = m = s = 0;
	var newTime = '';
 
	h = Math.floor( time / (60 * 60 * 1000) );
	time = time % (60 * 60 * 1000);
	m = Math.floor( time / (60 * 1000) );
	time = time % (60 * 1000);
	s = Math.floor( time / 1000 );

 
	newTime = pad(h, 2) + ':' + pad(m, 2) + ':' + pad(s, 2) ;
	return newTime;
}
 
function show() {
	$time = document.getElementById('time');
	update();
}
 
function update() {
	$time.value = formatTime(x.time());
}
 
function start() {
	clocktimer = setInterval("update()", 1);
	x.start();
}

function stop() {
	x.stop();
	clearInterval(clocktimer);
}

function display() {
	//alert(formatTime(x.time()));
        $timer = document.getElementById('timer');
       $timer.value = formatTime(x.time());
        return formatTime(x.time());
}

$(function(){
    
   $('.tiptext').tooltip();
  $("#StudentReport").tablesorter();
  $("#StudentReport").tablesorterPager({container: $("#StudentReportPager")});
  
  $("#ActiveStudents").tablesorter();
  $("#ActiveStudents").tablesorterPager({container: $("#ActiveStudentsPager")});
  
  $("#inActiveStudents").tablesorter();
  $("#inActiveStudents").tablesorterPager({container: $("#InActiveStudentsPager")});
  
  $("#ActiveSections").tablesorter();
  $("#ActiveSections").tablesorterPager({container: $("#ActiveSectionsPager")});
  
  $("#inActiveSections").tablesorter();
  $("#inActiveSections").tablesorterPager({container: $("#InActiveSectionsPager")});
  
  $("#ActiveModerators").tablesorter();
  $("#ActiveModerators").tablesorterPager({container: $("#ActiveModeratorsPager")});
  
  $("#inActiveModerators").tablesorter();
  $("#inActiveModerators").tablesorterPager({container: $("#inActiveModeratorsPager")});
  
  $("#table5").tablesorter();
  $("#table5").tablesorterPager({container: $("#customizedPager")});
  
  });

var $rows = $('tr');
$('#search').keyup(function() {
    var val = $.trim($(this).val()).replace(/ +/g, ' ').toLowerCase();
    
    $rows.show().filter(function() {
        var text = $(this).text().replace(/\s+/g, ' ').toLowerCase();
        return !~text.indexOf(val);
    }).hide();
});

(function(document) {
	'use strict';

	var LightTableFilter = (function(Arr) {

		var _input;

		function _onInputEvent(e) {
			_input = e.target;
			var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
			Arr.forEach.call(tables, function(table) {
				Arr.forEach.call(table.tBodies, function(tbody) {
					Arr.forEach.call(tbody.rows, _filter);
				});
			});
		}

		function _filter(row) {
			var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
			row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
		}

		return {
			init: function() {
				var inputs = document.getElementsByClassName('light-table-filter');
				Arr.forEach.call(inputs, function(input) {
					input.oninput = _onInputEvent;
				});
			}
		};
	})(Array.prototype);

	document.addEventListener('readystatechange', function() {
		if (document.readyState === 'complete') {
			LightTableFilter.init();
		}
	});

})(document);


window.location.hash="nb";
window.location.hash="nb";//again because google chrome don't insert first hash into history
window.onhashchange=function(){window.location.hash=" ";};